home *** CD-ROM | disk | FTP | other *** search
- >>>>> On Fri, 18 Mar 1994 18:55:07 -0500, stevenmz@teleport.com (Steven M. Ziuchkovski) said:
- > Errors-To: towfiq@sunsite.unc.edu
- > Errors-To: towfiq@sunsite.unc.edu
- > Originator: winsock@sunsite.unc.edu
-
- > I'm just starting out programming with the WINSOCK.DLL. I've got a few files
- > from rhino.microsoft.com, and did a LOT of reading, but the documentation does
- > not seem to be that good (well, to me).
-
- > Anyway, I'm trying to take a string (such as 'oak.oakland.edu') and determine
- > it's numeric IP address (141.210.10.117) as a small excersize for myself to
- > get started. I've gotten a small program that uses WSAStartup to determine the
- > number of sockets available (szMaxSockets), etc. Then, I use GetHostByName to
- > fill out a HostEnt record.
-
- > The information in WINSOCK.DOC (rhino.microsoft.com:/Specification/winsock.DOC
- > I think) is not to clear on the information of this record. I assume that the
- > h_Addr_List field contains a list of IP addresses (which I guess is what I'm
- > looking for). What format is this in? I cannot seem to be able to extract this
- > information correctly. Either the numbers are totally wrong from what they
- > should be, or produce a general protection fault.
-
- > Could someone please offer an explanation or pointers? I'm programming using
- > Borland Pascal v7.0.
-
- > Thanks,
- > Steve
-
- > ---
- > ///
- > Steven Ziuchkovski (0 0) stevenmz@teleport.com
- > ------------------------------ooO-(_)-Ooo------------------------------
-
-
- Steve,
-
- I don't have it in Pascal, but hope the following C code segment
- would help you.
-
- ----------
-
- struct hostent *host_ent;
- ...
-
- if ((host_ent = gethostbyname(buffer)) == NULL){
- rc = WSAGetLastError();
- print_error("winsock gethostbyname call failed -- %d", rc);
- return FALSE;
- }
- /* suppose the address is 141.210.10.117, then ...
- *(*(host_ent->h_addr_list)) is 141
- *(*(host_ent->h_addr_list) + 1) is 210
- *(*(host_ent->h_addr_list) + 2) is 10
- *(*(host_ent->h_addr_list) + 3) is 117
- */
-
- -----------
-
- dennis young
-
-
-